package org.wyy.vm.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import org.wyy.vm.entity.Video;
import org.wyy.vm.utils.ImageScale;
import org.wyy.vm.utils.VideoHelper;

import javax.swing.JButton;
import javax.swing.ImageIcon;

public class VideoDetail extends JFrame {

	private static final long serialVersionUID = 6286152651093921663L;
	private JPanel contentPane;

	/**
	 * Create the frame.
	 */
	public VideoDetail(Video v) {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 592, 526);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JLabel lblNewLabel = new JLabel("编 号");
		lblNewLabel.setBounds(50, 50, 54, 15);
		contentPane.add(lblNewLabel);

		JLabel lblNewLabel_1 = new JLabel("名 称");
		lblNewLabel_1.setBounds(50, 93, 54, 15);
		contentPane.add(lblNewLabel_1);

		JLabel lblNewLabel_2 = new JLabel("演 员");
		lblNewLabel_2.setBounds(50, 141, 54, 15);
		contentPane.add(lblNewLabel_2);

		JLabel lblNewLabel_3 = new JLabel("简 介");
		lblNewLabel_3.setBounds(50, 184, 54, 15);
		contentPane.add(lblNewLabel_3);

		JTextField idField = new JTextField("" + v.getId());
		idField.setEditable(false);
		idField.setBounds(114, 47, 205, 21);
		contentPane.add(idField);

		JTextField nameField = new JTextField(v.getName());
		nameField.setEditable(false);
		nameField.setBounds(114, 90, 205, 21);
		contentPane.add(nameField);

		JTextField actorsField = new JTextField(v.getActors());
		actorsField.setEditable(false);
		actorsField.setBounds(114, 138, 205, 21);
		contentPane.add(actorsField);

		JTextArea contentField = new JTextArea(v.getContent());
		contentField.setEditable(false);
		contentField.setLineWrap(true);
		contentField.setBounds(109, 179, 421, 151);
		contentPane.add(contentField);

		JButton btnNewButton = new JButton("退 出");
		btnNewButton.setBounds(437, 458, 93, 23);
		btnNewButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		contentPane.add(btnNewButton);

		JLabel lblNewLabel_4 = new JLabel();
		lblNewLabel_4.setBounds(324, 10, 234, 167);
		ImageIcon icon = new ImageIcon(v.getCoverImgPath());
		icon = ImageScale.getImage(icon, lblNewLabel_4.getWidth(), lblNewLabel_4.getHeight());
		lblNewLabel_4.setIcon(icon);
		contentPane.add(lblNewLabel_4);
		
		JButton btnNewButton_1 = new JButton("播放视频");
		btnNewButton_1.setBounds(50, 369, 144, 23);
		btnNewButton_1.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				VideoHelper.playVideo(v.getVideoPath());
				
			}
		});
		contentPane.add(btnNewButton_1);
	}
}
